/*
 * @Descripttion: 
 * @Author: chunhu-yin
 * @Date: 2021-03-12 14:33:16
 * @LastEditTime: 2021-03-22 10:40:00
 */
import React from 'react'
import { Trans } from 'react-i18next'
import { Card, Table, Button, Popconfirm } from 'antd'
import Http from './../../../request/index'
const columns = [
    {
        title: '用户名',
        dataIndex: 'sell_name',
    },
    {
        title: '经度',
        dataIndex: 'longitude',
    },
    {
        title: '纬度',
        dataIndex: 'latitude',
    },
    {
        title: '手机号',
        dataIndex: 'sell_phone',
    },

]
class List extends React.Component {
    state = {
        selectedRowKeys: [], // Check here to configure the default column
        loading: false,
        data: [],
        currentPageNum: 1,
        total: 0
    };
    onSelectChange = selectedRowKeys => {
        console.log('selectedRowKeys changed: ', selectedRowKeys);
        this.setState({ selectedRowKeys });
    };
    componentWillMount() {
        this.getDataList()
    }
    async  getDataList() {
        let data = {
            page: this.state.currentPageNum,
            pagesize: 10
        }
        var res = await Http.get('/tour/auth/getcustomers', data)
        console.log(res)
        if (res.code == 200) {
            this.setState({
                data: res.data.list,
                total: res.data.total
            })
        }
    }
    handleTableChange(pageNum) {
        if (pageNum != this.state.currentPageNum) {
            this.setState({
                currentPageNum: pageNum
            })
            this.getDataList()
        }
    }
    render() {
        const { loading, selectedRowKeys } = this.state;
        const rowSelection = {
            selectedRowKeys,
            onChange: this.onSelectChange,
        };
        const hasSelected = selectedRowKeys.length > 0;
        return (
            <div>
                <Table rowSelection={rowSelection} columns={columns} dataSource={this.state.data} rowKey='sell_id' pagination={{
                    defaultCurrent: this.state.currentPageNum,
                    total: this.state.total,
                    pageSize: 10,
                    onChange: this.handleTableChange.bind(this)

                }}
                    bordered={true}
                />
            </div>
        )
    }
}

export default List